home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / telecomm / uemlsrc.arc / tty.c < prev    next >
C/C++ Source or Header  |  1987-08-24  |  2KB  |  117 lines

  1. /*
  2.  * The routines in this file
  3.  * provide support for Atari ST terminals
  4.  * over a serial line. The serial I/O services are
  5.  * provided by routines in "osbind.h".
  6.  */
  7. #include        <stdio.h>
  8. #include        "ed.h"
  9.  
  10. #if     ST
  11. #include <osbind.h>
  12.  
  13. #define NROW    25                      /* Screen size.                 */
  14. #define NCOL    80                      /* Edit if you want to.         */
  15. #define MARGIN  8                       /* Size of minimum margin and   */
  16. #define SCRSIZ  64                      /* Scroll size of extended lines*/
  17. #define BIAS    0x20                    /* Origin 0 coordinate bias.    */
  18. #define ESC     0x1B                    /* ESC character.               */
  19. #define BEL     0x07                    /* ascii bell character         */
  20.  
  21. extern  int     ttopen();               /* Forward references.          */
  22. extern  int     ttgetc();
  23. extern  int     ttputc();
  24. extern  int     ttflush();
  25. extern  int     ttclose();
  26. extern  int     stmove();
  27. extern  int     steeol();
  28. extern  int     steeop();
  29. extern  int     stbeep();
  30. extern  int     stopen();
  31. extern  int     strev();
  32.  
  33. /*
  34.  * Dispatch table. All the
  35.  * hard fields just point into the
  36.  * terminal I/O code.
  37.  */
  38. TERM    term    = {
  39.         NROW-1,
  40.         NCOL,
  41.         MARGIN,
  42.         SCRSIZ,
  43.         &stopen,
  44.         &ttclose,
  45.         &ttgetc,
  46.         &ttputc,
  47.         &ttflush,
  48.         &stmove,
  49.         &steeol,
  50.         &steeop,
  51.         &stbeep,
  52.         &strev
  53. };
  54.  
  55. stmove(row, col)
  56. {
  57.         Bconout(2,ESC);
  58.         Bconout(2,'Y');
  59.         Bconout(2,row+BIAS);
  60.         Bconout(2,col+BIAS);
  61. }
  62.  
  63. steeol()
  64. {
  65.         Bconout(2,ESC);
  66.         Bconout(2,'K');
  67. }
  68.  
  69. steeop()
  70. {
  71.         Bconout(2,ESC);
  72.         Bconout(2,'J');
  73. }
  74.  
  75. stbeep()
  76. {
  77. #ifdef  BEL
  78.         Bconout(2,BEL);
  79.         ttflush();
  80. #endif
  81. }
  82.  
  83. strev(status)
  84. int status;
  85. {
  86.         if (status)
  87.                 {
  88.                 Bconout(2,ESC);
  89.                 Bconout(2,'p');
  90.                 }
  91.         else
  92.                 {
  93.                 Bconout(2,ESC);
  94.                 Bconout(2,'q');
  95.                 }
  96. }
  97.  
  98. stopen()
  99. {
  100. #if     V7
  101.         register char *cp;
  102.         char *getenv();
  103.  
  104.         if ((cp = getenv("TERM")) == NULL) {
  105.                 puts("Shell variable TERM not defined!");
  106.                 exit(1);
  107.         }
  108.         if (strcmp(cp, "st") != 0 && strcmp(cp, "z19") != 0) {
  109.                 puts("Terminal type not 'st25' or 'vt52' !");
  110.                 exit(1);
  111.         }
  112. #endif
  113.         ttopen();
  114. }
  115. #endif
  116.  
  117.